import { BottomInformation } from "../../styles/common";
import ItemCard from "../../components/card";
import React from "react";
import styled from "styled-components";
import { useNavigate } from "react-router-dom";

const Warp = styled.div`
  display: flex;
  flex-direction: column;
  height: 100vh;
`;

const UL = styled.ul`
  font-size: 18px;
  text-transform: capitalize;
  margin: unset;
  padding: unset;
  list-style-type: none;
  display: flex;
  flex-direction: row;
  background-color: black;
  justify-content: center;
  align-items: center;
  color: white;
`;

const LI = styled.li`
  padding: 10px;
  width: 20%;

  &:hover {
    background-color: #444;
    cursor: pointer;
  }
`;

const TopInfo = styled.div`
  background-color: white;
  text-align: center;
  font-size: 14px;
  padding: 5px 0;
`;

const Link = styled.div``;
const ContentWrap = styled.div`
  padding: 16px;
  background-color: #efefef;
  flex: 1;
  overflow: scroll;
`;
const ContentItem = styled.div`
  font-size: 16px;
  line-height: 20px;
  color: #333;
`;

const Root = () => {
  const navigate = useNavigate();

  const handleClick = (to) => {
    navigate(to);
  };

  const information = [
    {
      key: 1,
      title: "root",
      content: "with navigation",
    },
    {
      key: 2,
      title: "chart",
      content: "echarts line example",
    },
    {
      key: 3,
      title: "about",
      content: '... don"t know yet',
    },
    {
      key: 4,
      title: "root",
      content: "with navigation",
    },
    {
      key: 5,
      title: "chart",
      content: "echarts line example",
    },
    {
      key: 6,
      title: "about",
      content: '... don"t know yet',
    },
    {
      key: 7,
      title: "root",
      content: "with navigation",
    },
    {
      key: 8,
      title: "chart",
      content: "echarts line example",
    },
    {
      key: 9,
      title: "about",
      content: '... don"t know yet',
    },
  ];

  const buildCardItems = (information) =>
    information.map((item) => <ItemCard {...item} />);

  return (
    <Warp>
      <TopInfo>this is top information bar</TopInfo>
      <UL>
        <LI>
          <Link onClick={() => handleClick("/home")}>home</Link>
        </LI>
        <LI>
          <Link onClick={() => handleClick("/chart")}>chart</Link>
        </LI>
        <LI>
          <Link onClick={() => handleClick("/about")}>about</Link>
        </LI>
      </UL>
      <ContentWrap>
        {buildCardItems(information)}
        <BottomInformation>... The End ...</BottomInformation>
      </ContentWrap>
    </Warp>
  );
};

export default Root;
